//
//  SVSingleHeader.h
//  SportsWin
//
//  Created by douniwan on 2019/7/16.
//  Copyright © 2019年 douniwan. All rights reserved.
//

#ifndef SVSingleHeader_h
#define SVSingleHeader_h


//.h头文件中的单例宏
#define IMSingletonH(name) + (instancetype)shared##name;

//.m文件中的单例宏
#define IMSingletonM(name) \
static id _instance;\
+ (instancetype)allocWithZone:(struct _NSZone *)zone{\
static dispatch_once_t onceToken;\
dispatch_once(&onceToken, ^{\
_instance = [super allocWithZone:zone];\
});\
return _instance;\
}\
+ (instancetype)shared##name{\
static dispatch_once_t onceToken;\
dispatch_once(&onceToken, ^{\
_instance = [[self alloc] init];\
});\
return _instance;\
}\
- (id)copyWithZone:(NSZone *)zone{\
return _instance;\
}


#endif /* SVSingleHeader_h */
